﻿@* --------------------------------------------------------------------------------------------------------------------
// <copyright file="Paging.cshtml" company="Devbridge Group LLC">
// 
// Copyright (C) 2015,2016 Devbridge Group LLC
// 
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/. 
// </copyright>
// 
// <summary>
// Better CMS is a publishing focused and developer friendly .NET open source CMS.
// 
// Website: https://www.bettercms.com 
// GitHub: https://github.com/devbridge/bettercms
// Email: info@bettercms.com
// </summary>
// -------------------------------------------------------------------------------------------------------------------- *@
@using BetterCms.Module.Root.Content.Resources

<!-- ko if: totalPages() > 0 -->
<div class="bcms-pager bcms-clearfix">
    <span class="bcms-pager-text">@RootGlobalization.Paging_Page_Title:</span>

    <!-- ko if: pagingLowerBound() > 1 -->
    <a class="bcms-pager-no" data-page-number="1" data-bind="click: openPage.bind($data, 1)">1 </a>
    <!-- ko if: pagingLowerBound() != 2 -->
    <span class="bcms-pager-text">...</span>
    <!-- /ko-->
    <!-- /ko-->

    <!-- ko foreach: pages() -->
    <!-- ko if: $data == $parent.pageNumber() -->
    <a class="bcms-pager-no bcms-active-pager" data-bind="html: $data"></a>
    <!-- /ko -->
    <!-- ko ifnot: $data == $parent.pageNumber() -->
    <a class="bcms-pager-no" data-bind="css: { 'bcms-active-pager': $data == $parent.pageNumber() }, attr: { 'data-page-number': $data }, html: $data, click: $parent.openPage.bind($parent, $data)"></a>
    <!-- /ko -->
    <!-- ko if: $data != $parent.pageNumber() && $data == $parent.pagingUpperBound() && $data <= $parent.totalPages() - 1  -->
    <span class="bcms-pager-text">...</span>
    <!-- /ko -->
    <!-- /ko -->

    <!-- ko if: pagingUpperBound() < totalPages() -->
    <a class="bcms-pager-no" data-bind="attr: { 'data-page-number': totalPages() }, html: totalPages(), click: openPage.bind($data, totalPages())"></a>
    <!-- /ko -->

    <!-- ko if: pageNumber() == totalPages() -->
    <a class="bcms-pager-next">@RootGlobalization.Button_Paging_Next</a>
    <!-- /ko -->
    <!-- ko ifnot: pageNumber() == totalPages() -->
    <a class="bcms-pager-next" data-bind="attr: { 'data-page-number': pageNumber() + 1, href: '#' }, click: openPage.bind($data, pageNumber() + 1)">@RootGlobalization.Button_Paging_Next</a>
    <!-- /ko -->

    <!-- ko if: pageNumber() == 1 -->
    <a class="bcms-pager-prev">@RootGlobalization.Button_Paging_Previous</a>
    <!-- /ko -->
    <!-- ko ifnot: pageNumber() == 1 -->
    <a class="bcms-pager-prev" data-bind="attr: { 'data-page-number': pageNumber() - 1, href: '#' }, click: openPage.bind($data, pageNumber() - 1)">@RootGlobalization.Button_Paging_Previous</a>
    <!-- /ko -->
</div>
<!-- /ko -->
